package com.muyun.data.modeler.sysadmin.domain.model.entity;

import com.muyun.data.modeler.infrastructure.general.specs.AggregateRoot;
import com.muyun.data.modeler.infrastructure.general.toolkit.BCryptToolkit;
import org.springframework.data.neo4j.core.schema.Node;

/**
 * 用户模型
 * @author muyun12
 * @date 2020-12-19 14:09:23
 * @since 0.1.0
 */
@Node
public class User extends AggregateRoot {

    private String username;
    private String password;

    public User(){

    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 用户敏感信息加密
     *
     * @return
     */
    public User encrypt(){
        // 密码加密
        String password = BCryptToolkit.hashpw(getPassword(), BCryptToolkit.gensalt());
        setPassword(password);
        return this;
    }
}
